<template>
  <el-card class="header-card">
    <div class="card-wrap">
      <el-page-header content="审批详情" @back="goBack" />
      <div v-if="isApproval && nodeId != 'ACT_010'">
        <el-button @click="goBack">取消</el-button>
        <el-button type="primary" :loading="model.saveLoading" @click="handleSave">保存</el-button>
        <template v-if="!model.isNoReject">
          <el-button type="primary" :loading="model.saveLoading" @click="handleReject">驳回</el-button>
        </template>
        <el-button
          type="primary"
          :loading="model.saveLoading"
          @click="handleFlowNotify" v-if="modeType!='toread'&&modeType!='read'"
          >知会</el-button
        >
        <el-button type="primary" :loading="model.saveLoading" @click="handleSubmit">提交</el-button>
      </div>

      <template v-else>
          <div>
            <el-button
              type="primary"
              @click="toEdit" v-if="isApproval && nodeId == 'ACT_010'"
              >重新编辑</el-button
            >
            <el-button
              type="primary"
              :loading="model.saveLoading"
              @click="handleFlowNotify" v-if="modeType!='toread'&&modeType!='read'"
              >知会</el-button
            >
            <el-button
              type="primary"
              :loading="model.saveLoading"
              @click="handleRecall" v-if='canRecall == 1'
              >撤回</el-button
            >
          </div>
      </template>
    </div>
  </el-card>
  <br />

  <el-card class="base-card">
    <template #header>
      <div class="card-box-header">
        <span>项目基本信息</span>
        <div v-if="show1" @click="show1 = !show1" class="header-btn">
          收起
          <i class="el-icon-arrow-down"></i>
        </div>
        <div v-else @click="show1 = !show1" class="header-btn">
          展开
          <i class="el-icon-arrow-right"></i>
        </div>
      </div>
    </template>
    <div v-show="show1">
      <BasicsInfo :projectInfo="projectInfo" />
    </div>
  </el-card>
  <br />

  <!-- 实施信息 -->
  <template v-if='projectInfo.reviewStageCode == 3'>
    <el-card>
      <template #header>
        <div class="card-box-header">
          <span>项目实施计划</span>
          <div v-if="show8" @click="show8 = !show8" class="header-btn">
            收起
            <i class="el-icon-arrow-down"></i>
          </div>
          <div v-else @click="show8 = !show8" class="header-btn">
            展开
            <i class="el-icon-arrow-right"></i>
          </div>
        </div>
      </template>
      <div v-show="show8">
        <Implementation :projectInfo="peojectDetailData" />
      </div>
    </el-card>
    <br />
  </template>

  <!-- 验收 -->
  <template v-else-if='projectInfo.reviewStageCode == 4'>
    <el-card>
      <template #header>
        <div class="card-box-header">
          <span>项目验收</span>
          <div v-if="show8" @click="show8 = !show8" class="header-btn">
            收起
            <i class="el-icon-arrow-down"></i>
          </div>
          <div v-else @click="show8 = !show8" class="header-btn">
            展开
            <i class="el-icon-arrow-right"></i>
          </div>
        </div>
      </template>
      <div v-show="show8">
        <Check :projectInfo="peojectDetailData" />
        <Tab7/>
      </div>
    </el-card>
    <br />
  </template>

  <!-- 后评价 -->
  <template v-else-if='projectInfo.reviewStageCode == 5'>
    <el-card>
      <template #header>
        <div class="card-box-header">
          <span>后评价</span>
          <div v-if="show8" @click="show8 = !show8" class="header-btn">
            收起
            <i class="el-icon-arrow-down"></i>
          </div>
          <div v-else @click="show8 = !show8" class="header-btn">
            展开
            <i class="el-icon-arrow-right"></i>
          </div>
        </div>
      </template>

      <div v-show="show8">
        <Evaluate :projectInfo="peojectDetailData" />
      </div>
    </el-card>
    <br />
  </template>

  <!-- 终止，变更 -->
   <template v-else-if='projectInfo.reviewStageCode == 6 || projectInfo.reviewStageCode == 7'>
    <el-card>
      <template #header>
        <div class="card-box-header">
          <span v-if='projectInfo.reviewStageCode == 7'>终止申请信息</span>
          <span v-else>变更申请信息</span>
          <div v-if="show7" @click="show7 = !show7" class="header-btn">
            收起
            <i class="el-icon-arrow-down"></i>
          </div>
          <div v-else @click="show7 = !show7" class="header-btn">
            展开
            <i class="el-icon-arrow-right"></i>
          </div>
        </div>
      </template>
      <div v-show="show7">
        <ChangeInfo :projectInfo="peojectDetailData"/>
      </div>
    </el-card>
    <br />
  </template>

  <template v-else>
    <el-card>
      <template #header>
        <div class="card-box-header">
          <span>评审内容</span>
          <div v-if="show2" @click="show2 = !show2" class="header-btn">
            收起
            <i class="el-icon-arrow-down"></i>
          </div>
          <div v-else @click="show2 = !show2" class="header-btn">
            展开
            <i class="el-icon-arrow-right"></i>
          </div>
        </div>
      </template>
      <div v-show="show2">
        <ReviewInfo :projectInfo="projectInfo" :peojectDetailData="peojectDetailData" />
      </div>
    </el-card>
    <br />
  </template>

  <template v-if='nodeId === "ACT_012" || nodeId === "END"'>
    <el-card class="expert-card">
      <template #header>
        <div class="card-box-header">
          <span>专家评审意见</span>
          <div v-if="show3" @click="show3 = !show3" class="header-btn">
            收起
            <i class="el-icon-arrow-down"></i>
          </div>
          <div v-else @click="show3 = !show3" class="header-btn">
            展开
            <i class="el-icon-arrow-right"></i>
          </div>
        </div>
      </template>
      <div v-show="show3">
        <ExperReviewtList :projectInfo="projectInfo" />
        <BuildApproval :projectInfo="projectInfo" class="mg-top"></BuildApproval>
      </div>
    </el-card>
    <br />
  </template>

  <template v-if="isApproval">
    <el-card>
      <template #header>
        <div class="card-box-header">
          <span>待处理</span>
          <div v-if="show4" @click="show4 = !show4" class="header-btn">
            收起
            <i class="el-icon-arrow-down"></i>
          </div>
          <div v-else @click="show4 = !show4" class="header-btn">
            展开
            <i class="el-icon-arrow-right"></i>
          </div>
        </div>
      </template>
      <div v-show="show4">
        <el-link :underline="false" @click="toEdit" v-if='nodeId == "ACT_010"' class="to-edit">重新编辑</el-link>
        <PendingInfo :projectInfo="projectInfo" ref="pendRef" v-else />
      </div>
    </el-card>
    <br />
  </template>
  <!-- 流程状态 -->
  <el-card>
    <template #header>
      <div class="card-box-header">
        <span> 流程状态</span>
        <div v-if="show5" @click="show5 = !show5" class="header-btn">
          收起
          <i class="el-icon-arrow-down"></i>
        </div>
        <div v-else @click="show5 = !show5" class="header-btn">
          展开
          <i class="el-icon-arrow-right"></i>
        </div>
      </div>
    </template>
    <div v-if="currentStep">
      <el-collapse-transition>
        <!-- <status-info :currentStep="currentStep" :steps="steps" :isSkip="isSkipLx" /> -->
        <img :src="currentStep" />
      </el-collapse-transition>
    </div>
  </el-card>
  <br />

  <!-- 流转记录 -->
  <el-card>
    <template #header>
      <div class="card-box-header">
        <span> 流转记录</span>
        <div v-if="show6" @click="show6 = !show6" class="header-btn">
          收起
          <i class="el-icon-arrow-down"></i>
        </div>
        <div v-else @click="show6 = !show6" class="header-btn">
          展开
          <i class="el-icon-arrow-right"></i>
        </div>
      </div>
    </template>
    <div v-show="show6">
      <el-collapse-transition>
        <approval-info :activities="approveRecord" />
      </el-collapse-transition>
    </div>
  </el-card>

  <approveDialog v-if="approveDialogVisiable" :nodeId="nodeId" :flowType="model.flowType" @cancel="cancel"
    @sure="sureSubmit"></approveDialog>

  <rejectDialog v-if="rejectDialogVisiable" :nodeId="nodeId" :isSkip="isSkipLx" :flowType="model.flowType"
    @cancel="cancel" @sure="sureRejectSubmit"></rejectDialog>

  <addUser @sure="submitFlowNotify" @cancel="addUserDialogVisiable = false" title="请选择知会人员" v-if="addUserDialogVisiable"></addUser>

  <!-- 专家承诺书弹窗 -->
  <Commitment v-if="!isCommitment && modeType === 'approval'" :isCommitment="isCommitment" :projectInfo="projectInfo" @changeIsCommitment="changeIsCommitment" @back="handelBack"/>
</template>

<script lang="ts" setup>
  import { ref, reactive } from "vue";
  import { useRouter, useRoute } from "vue-router";
  import Tab7 from "/@/views/project/detail/components/descTabs/tab7.vue";
  import addUser from "../addUser.vue";
  import BasicsInfo from "../BasicsInfo.vue";
  import ChangeInfo from "../ChangeInfo.vue";
  import Implementation from "../Implementation.vue";
  import Check from "../Check.vue";
  import Evaluate from "../Evaluate.vue";
  import BuildApproval from "../BuildApproval.vue";
  import ReviewInfo from "./ReviewInfo.vue";
  import PendingInfo from "./PendingInfo.vue";
  import ExperReviewtList from "../ExperReviewtList.vue";
  import approveDialog from "/@/components/approveDialog/index.vue";
  import rejectDialog from "/@/components/rejectDialog/index.vue";
  import StatusInfo from "/@/components/StatusInfo/index.vue";
  import ApprovalInfo from "/@/components/ApprovalInfo/index.vue";
  import { flowTypeObj } from "/@/components/approveDialog/type";
  import { flowStatusObj } from "/@/components/StatusInfo/type";
  import { flowFormArray } from "/@/utils/flowForm";
  import { storageLocal } from "/@/utils/storage";
  import { stageToPath } from "/@/utils/globalConstant";
  import {getApproveImg} from "/@/api/project";
  import {
    getProjectInfo,
    updateExpertRvwOpinion,
    saveRvwSummary,
    flowSubmit,
    flowReject,
    getApproveHandlerId,
  } from "/@/api/project";
  import {
    saveStorageFormData,
    getStorageFormData,
    postRecall,
    flowNotify
  } from "/@/api/approval";
  import { cloneDeep } from "lodash-es";
  import NotifMessage from "/@/utils/message/notification";
  import Commitment from './commitment.vue'
  const props = defineProps({
    canRecall: {
      type: String,
      default:""
    },
    approveRecord:{
      type: Array,
      default:() => []
    }
  });
  const router = useRouter();
  const route = useRoute();

  const isCommitment = ref<boolean>(true)

  const pendRef = ref<HTMLFormElement | null>(null) as any;
  let show1 = ref<boolean>(true);
  let show2 = ref<boolean>(true);
  let show3 = ref<boolean>(true);
  let show4 = ref<boolean>(true);
  let show5 = ref<boolean>(true);
  let show6 = ref<boolean>(true);
  let show7 = ref<boolean>(true);
  let show8 = ref<boolean>(true);
  let addUserDialogVisiable = ref<boolean>(false);    //人员选择器弹窗
  let approveDialogVisiable = ref<boolean>(false); // 点击提交弹窗，选择下一步审批人
  let rejectDialogVisiable = ref<boolean>(false); // 点击驳回弹窗，选择下一步审批人
  const nodeId = route.query.nodeId ? route.query.nodeId : "ACT_010";
  const isApproval = route.query.mode === "approval" ? true : false;
  const modeType = route.query.mode;
  const isSkipLx = route.query.isSkipLx;
  const flowType = route.query.flowType;
  const projectManageId = route.query.projectManageId;
  const billName = route.query.billName;
  const instanceId = route.query.instanceId;
  const busCategoryName = route.query.busCategoryName;
  const currentStep = ref(null);
  const steps = ref([]);
  const projectInfo = ref({});
  const peojectDetailData = ref({})
  const postData = ref({})
  const option = ref([]);
  const model = reactive({
    flowType: flowType,
    approveHandlerId: null,
    saveLoading: false,
    isNoReject: false,
    dialogType: "approval"
  });

  // 关闭承诺书弹窗
  const changeIsCommitment = (val) => {
    isCommitment.value = val
  }

  //审批流程
  const flowPassData = reactive({
    formBaseInfo: {
      id: route.query.id,
      acceptUsers: null
    },
    flowFormData: {
      approvalComments: "",
      approvalResult: "",
      businessId: route.query.id,
      flowId: route.query.flowId,
      flowTypeCode: flowType,
      instanceId: instanceId,
      nodeId: nodeId,
      remarks: "",
      saveState: "1"
    },
    formSubMap: {
      stageStatus: flowType,
      flowType: flowType,
      nodeId: nodeId,
      procInstId: instanceId,
      taskId: "",
      opinion: "",
      assignee: null,
      isChargehand: "1", //1：向下提交到下一步：0：回退到某一步
      specialReject: "0"
    },
    tmpStorage: {
      nodeId: nodeId,
      flowId: route.query.flowId,
      taskId: "",
      handlerId: null,
      valueJson: ""
    }
  });

  const flowRejectData = reactive({
    formRejectMap: {
      procInstId: route.query.instanceId,
      nodeId: route.query.nodeId,
      taskId: "",
      opinion: ""
    }
  });

  // 点击提交，校验通过后，弹窗：选择下一节点处理人
  const handleSubmit = async () => {
    model.dialogType = "approval";
    const isValid = await pendRef.value.validate()
    if (!isValid) {
      NotifMessage.warning("请补充必填信息后，再次操作！");
      return
    }
    approveDialogVisiable.value = true;
  };

  // 点击弹窗的确定后、提交，单据往下流转
  const sureSubmit = async params => {
    approveDialogVisiable.value = false;
    model.saveLoading = true;
    postData.value = Object.assign({},pendRef.value.model.formData);
    //专家审批流程，先保存表单更新业务状态
    if (nodeId === "ACT_011") {
      postData.value.reviewCommentsName = postData.value.reviewCommentsCode.dicValue;
      postData.value.reviewCommentsCode = postData.value.reviewCommentsCode.dicCode;
      flowPassData.flowFormData.approvalComments = postData.value.reviewComments;
      flowPassData.flowFormData.approvalResult = postData.value.reviewCommentsCode; //同意：1，不同意：0
      flowPassData.flowFormData.remarks = postData.value.reviewComments;
      option.value = [
        { name: "审批意见", content: `${postData.value.reviewCommentsName}`, type: "textarea" },
        { name: "备注", content: `${postData.value.reviewComments}`, type: "textarea" },
      ];
      postData.value.reviewAttachment = JSON.stringify(pendRef.value.model.formData.reviewAttachment);
      const { code, message } = await updateExpertRvwOpinion(postData.value);
      model.saveLoading = false;
      if (code === 200) {
        passProcess(params);
      } else {
        NotifMessage.error(message);
      }
    } else {//专家评审汇总
      postData.value.reviewTemplateAttachment = JSON.stringify(postData.value.reviewTemplateAttachment);
      flowPassData.flowFormData.approvalComments = postData.value.remark;
      flowPassData.flowFormData.approvalResult = postData.value.reviewCategoryCode; //同意：1，不同意：0
      flowPassData.flowFormData.remarks = postData.value.remark;
      option.value = [
        { name: "审批意见", content: `${postData.value.reviewCategoryName}`, type: "textarea" },
        { name: "备注", content: `${postData.value.remark}`, type: "textarea" },
      ];
      const { code, message } = await saveRvwSummary(postData.value);
      model.saveLoading = false;
      if (code === 200) {
        passProcess(params);
      } else {
        NotifMessage.error(message);
      }
    }
  };

  // 流程审批通过
  const passProcess = async params => {
    const info = storageLocal.getItem("rdms-info");
    const userId = info?.userId;
    flowPassData.tmpStorage.handlerId = userId;
    if (params?.feasibilityreList && params.feasibilityreList.length) {
      //是否支持上传附件
      //会签记录
      const file = JSON.stringify(params.feasibilityreList);
      option.value.push({ name: "会签记录", content: `${file}`, type: "file" })
    }
    if (!params.isSingle) {
      //会签，多人审批
      if (params?.handlederId && params.handlederId.length) {
        const idList = params.handlederId.map(item => {
          return item.id;
        });
        flowPassData.formBaseInfo.acceptUsers = idList.join() || userId;
        flowPassData.formSubMap.assignee = idList.join() || userId;
      }
    } else {
      //专家评审的节点，默认下一步处理人都是路流程发起人
      if (flowType === "3009") {//专家审批流程
        flowPassData.formBaseInfo.acceptUsers = projectInfo.value.createUser || userId;
        flowPassData.formSubMap.assignee = projectInfo.value.createUser || userId;
      } else {
        flowPassData.formBaseInfo.acceptUsers = params?.handlederId?.id || userId;
        flowPassData.formSubMap.assignee = params?.handlederId?.id || userId;
      }
    }

    if (params.nextJumpTo && params.nextJumpTo.length) {
      //当前节点可以选择多下级审批节点
      flowPassData.formSubMap.isChargehand = params.nextJumpObj.isChargehand;
    } else {
      if (model.dialogType === "reject") {
        //通过当前流程，流程退回指定节点或者非正常流程
        flowPassData.formSubMap.isChargehand = params.backJumpObj.isChargehand;
        flowPassData.formBaseInfo.acceptUsers = model.approveHandlerId; //回退节点的处理人
        flowPassData.formSubMap.assignee = model.approveHandlerId;
      } else {
        //通过当前流程，流程流转到后续流程（(正常流程)）
        flowPassData.formSubMap.isChargehand = "1";
      }
    }
    model.saveLoading = true;
    flowPassData.tmpStorage.valueJson = JSON.stringify(flowPassData.formSubMap);
    flowPassData.formSubMap.opinion = JSON.stringify(option.value)
    const { code, message } = await flowSubmit(flowPassData);
    if (code === 200) {
      NotifMessage.success(message);
      goBack();
    } else {
      NotifMessage.error(message);
    }
  };

  //点击驳回(可选驳回到第一个节点，或者上一节点以及指定节点)
  const handleReject = async () => {
    model.dialogType = "reject";
    rejectDialogVisiable.value = true;
  };

  //确定驳回(或者驳回指点节点)
  const sureRejectSubmit = async params => {
    model.saveLoading = true;
    if (params.backJumpObj.isRejectBack) {
      //是否真驳回到上一步
      const option = [{ name: "驳回意见", content: `${params.remark}`, params: "textarea" }];
      flowRejectData.formRejectMap.opinion = JSON.stringify(option);
      const { code, message } = await flowReject(flowRejectData);
      if (code === 200) {
        NotifMessage.success(message);
        goBack();
      } else {
        NotifMessage.error(message);
      }
    } else {
      //驳回到第一步或者指定节点
      if (model.flowType) {
        //流程退回指定节点,获取节点的处理人
        const backNodeId = params.backJumpObj.backJumpToId; //驳回到的指定节点
        backNodeId && getApproveUserId(backNodeId, params);
      }
    }
  };

  // 保存审批数据
  const handleSave = async () => {
    const isValid = await pendRef.value.validate()
    if (isValid) {
      const info = storageLocal.getItem("rdms-info");
      const postData = Object.assign({},pendRef.value.model.formData);
      postData.reviewTemplateAttachment = JSON.stringify(postData.reviewTemplateAttachment);
      postData.reviewCommentsName = postData.reviewCommentsCode.dicValue;
      postData.reviewCommentsCode = postData.reviewCommentsCode.dicCode;
      postData.reviewAttachment = JSON.stringify(postData.reviewAttachment);
      let params = {
        nodeId: nodeId,
        taskId: projectInfo.value.taskId,
        flowId: route.query.flowId,
        handlerId: info ? info?.userId : "",
        userId: info ? info?.userId : "",
        handlerName: info ? info?.name : "",
        valueJson: JSON.stringify(postData)
      };
      try {
        const { code, message } = await saveStorageFormData(params);
        if (code === 200) {
          goBack();
          NotifMessage.success("保存成功");
        } else {
          NotifMessage.error(message);
        }
      } catch (err) {
        console.log(err);
      }
    }else{
      NotifMessage.warning("请补充必填信息后，再次操作！");
      return
    }
  };

  //流程撤回
  const handleRecall = async () => {
    try {
      const preNodeId = route.query.preNodeId ? route.query.preNodeId : "ACT_010";
      const params = {instanceId,nodeId:preNodeId};
      const { code, message } = await postRecall(params);
      if (code === 200) {
        NotifMessage.success(message);
        goBack();
      } else {
        message && NotifMessage.error(message);
      }
    } catch (err) {
      console.log(err);
    }
  };

  //选择知会人员
  const handleFlowNotify = async () => {
    addUserDialogVisiable.value = true;
  };

  //确定知会
  const submitFlowNotify = async parmas => {
    const notifys = [];
    const id = parmas?.userInfo?.id;
    const info = storageLocal.getItem("rdms-info");
    notifys.push(id);
    let taskId = projectInfo.value.taskId;
    if(!taskId){
      const len = props.approveRecord.length
      taskId = len && props.approveRecord[len-1]?.taskId;
    }
    let params = {
      assignee: info?.userId,
      instanceId: instanceId,
      taskId: taskId,
      notifys: notifys
    };
    try {
      const { code, message } = await flowNotify(params);
      if (code === 200) {
        addUserDialogVisiable.value = false;
        NotifMessage.success(message);
        goBack();
      } else {
        NotifMessage.error(message);
      }
    } catch (err) {
      console.log(err);
    }
  };

  // 获取保存的数据
  const getStorageFormDataInfo = async () => {
    const info = storageLocal.getItem("rdms-info");
    let params = {
      nodeId: nodeId,
      taskId: projectInfo.value.taskId,
      flowId: route.query.flowId,
      handlerId: info ? info?.userId : ""
    };
    const { code, data } = await getStorageFormData(params);
    if (code === 200) {
      if (data?.valueJson) {
        const saveData = JSON.parse(data.valueJson);
        projectInfo.value.reviewCommentsCode = saveData.reviewCommentsCode;
        projectInfo.value.reviewCommentsName = saveData.reviewCommentsName;
        projectInfo.value.reviewComments = saveData.reviewComments;
        projectInfo.value.ecoAccurate = saveData.ecoAccurate;
        projectInfo.value.ecoCompliance = saveData.ecoCompliance;
        projectInfo.value.ecoRational = saveData.ecoRational;
        projectInfo.value.tcnAdvance = saveData.tcnAdvance;
        projectInfo.value.tcnInnovation = saveData.tcnInnovation;
        projectInfo.value.tcnJbzx = saveData.tcnJbzx;
        projectInfo.value.ext1 = saveData.ext1;
        projectInfo.value.ext2 = saveData.ext2;
        projectInfo.value.ext3 = saveData.ext3;
        projectInfo.value.ext4 = saveData.ext4;
        projectInfo.value.ext5 = saveData.ext5;
        projectInfo.value.ext6 = saveData.ext6;
        projectInfo.value.remark = saveData.remark;
        projectInfo.value.reviewCategoryCode = saveData.reviewCategoryCode;
        projectInfo.value.reviewCategoryName = saveData.reviewCategoryName;
        projectInfo.value.reviewTemplateAttachmentArr = saveData.reviewTemplateAttachmentArr;
        projectInfo.value.reviewTemplateAttachment = JSON.parse(saveData.reviewTemplateAttachment);
        projectInfo.value.reviewAttachment = saveData.reviewAttachment?JSON.parse(saveData.reviewAttachment):[];
      }
    }
  };

  //获取某一节点的处理人
  const getApproveUserId = async (nodeId, params) => {
    model.saveLoading = true;
    const instanceId = route.query.instanceId;
    const { code, data } =
      instanceId && (await getApproveHandlerId(instanceId, nodeId));
    if (code === 200) {
      model.approveHandlerId = data[0];
      flowPassData.flowFormData.remarks = params.remark;
      option.value = [
        { name: "备注", content: `${params.remark}`, type: "textarea" },
      ];
      passProcess(params);
    } else {
      NotifMessage.error("获取处理人失败");
    }
  };

  //查询专家审批详情
  const initApprovalInfo = async () => {
    try {
      const getDetail = flowFormArray[flowType].interface;
      const queryId = route.query?.id ?? "";
      const { code, data } = queryId && (await getDetail({ id: queryId }));
      if (code === 200) {
        isCommitment.value = data.agree;
        projectInfo.value = data;
        projectInfo.value.flowType = flowType;
        flowPassData.tmpStorage.taskId = data.taskId;
        flowPassData.formSubMap.taskId = data.taskId;
        flowRejectData.formRejectMap.taskId = data.taskId;
        projectInfo.value.billName = billName;
        projectInfo.value.busCategoryName = busCategoryName;
        projectInfo.value.projectManageId = projectManageId;
        model.flowType = flowType;
        if (model.flowType) {
          model.isNoReject = flowTypeObj[model.flowType][nodeId].isNoReject; //不展示驳回按钮
        }
        getProjectFormInfo()
        getStorageFormDataInfo()
        getStep();
      }
    } catch (err) {
      console.log(err);
    }
  };

  //查询项目详情
  const getProjectFormInfo = async () => {
    const { code, data } = await getProjectInfo({ id: projectManageId });
    if (code === 200) {
      peojectDetailData.value = cloneDeep(data);
      peojectDetailData.value.stageStatus = projectInfo.value.reviewStageCode;
      // projectInfo.value.billName = billName;
      // projectInfo.value.busCategoryName = busCategoryName;
      // projectInfo.value.projectManageId = projectManageId;
      // projectInfo.value.flowType = flowType;
      // flowPassData.tmpStorage.taskId = data.taskId;
      // flowPassData.formSubMap.taskId = data.taskId;
      // flowRejectData.formRejectMap.taskId = data.taskId;
    }
  };

  //获取流程转态
  const getStep = async () => {
    const instanceId = route.query.instanceId;
    const { code, data } = await getApproveImg(instanceId);
    if (code === 200) {
      currentStep.value = data;
    }
  };

  const toEdit = async () => {
    let pathUrl = stageToPath[flowType];
    let pathQuery = {
      flowType: flowType,
      id: route.query.id,
      projectId: projectManageId,
      taskId: projectInfo.value.taskId,
      flowId: route.query.flowId,
      instanceId: instanceId,
      nodeId: nodeId,
      mode: "edit"
    };
    router.push({
      path: pathUrl,
      query: pathQuery
    });
  }

  const goBack = () : void => {
    router.back()
  };

  const cancel = async () => {
    rejectDialogVisiable.value = false;
    approveDialogVisiable.value = false;
    model.saveLoading = false;
  };
  initApprovalInfo();

  const handelBack = () => {
    console.log("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
    goBack()
  }
</script>

<style lang="scss" scoped>
  .empt-content {
    height: calc(100vh - 200px);
    width: 100%;
  }

  .card-wrap {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .card-box-header {
    display: flex;
    justify-content: space-between;
    align-items: center;

    .header-btn {
      font-size: 14px;
      cursor: pointer;
    }
  }
  .mg-top{
    margin-top: 20px;
  }
  .to-edit{
    color:#f9b05d;
    font-size: 16px;
  }
  .expert-card{
    :deep .el-card__body{
      padding-top:0 !important
    }
  }
</style>
